package utils
{
	public class StringUtils
	{
		public function StringUtils()
		{
		}
		
		public static function formatNullString(str:String):String
		{
			return (str == null || str == "null" ) ? "" : str;
		}
		
		/**
		 *  是否为空字符串
		 **/
		public static function isNullEmptyString(str:String):Boolean
		{
			return (str == null || str == "" || str == "null");
		}
		
		/**
		 * 将字符串转换成十六进制字符串
		 */
		public static function toHex(str:String):String
		{
			var outStr:String = "";
			if ( str != null ) {
				for (var ii:int=0;ii < str.length; ii++)
				{
					var tempChar:String = str.charAt(ii);
					if ( !isNaN(Number(tempChar)) ) {
						outStr += parseInt(tempChar, 16);
					} else {
						throw new Error("字符串格式不对.");
					}
				}
			} else {
				outStr = null;
			}
			return outStr;
		}
	}
}